home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / fromspacelove.swf / scripts / frame_5 / PlaceObject2_387_4 / CLIPACTIONRECORD onClipEvent(enterFrame).as next >
Encoding:
Text File  |  2006-06-13  |  11.6 KB  |  361 lines

  1. onClipEvent(enterFrame){
  2.    if(!Paused)
  3.    {
  4.       if(UFO.Active)
  5.       {
  6.          UFO.UnactiveCount = 0;
  7.          if(Key.isDown(40))
  8.          {
  9.             if(UFO.Boxz < MapD)
  10.             {
  11.                UFO.ZSpeed += 2;
  12.             }
  13.          }
  14.          if(Key.isDown(38))
  15.          {
  16.             if(UFO.Boxz > 0)
  17.             {
  18.                UFO.ZSpeed -= 2;
  19.             }
  20.          }
  21.          if(Key.isDown(37))
  22.          {
  23.             if(UFO.Boxx > 0)
  24.             {
  25.                UFO.XSpeed -= 4;
  26.             }
  27.          }
  28.          if(Key.isDown(39))
  29.          {
  30.             if(UFO.Boxx < MapW)
  31.             {
  32.                UFO.XSpeed += 4;
  33.             }
  34.          }
  35.          if(Key.isDown(32))
  36.          {
  37.             if(UFO.ReadyNum > 0)
  38.             {
  39.                UFO.Releasing = true;
  40.                UFO.Active = false;
  41.             }
  42.             else
  43.             {
  44.                RejSound.start();
  45.             }
  46.          }
  47.       }
  48.       else
  49.       {
  50.          UFO.UnactiveCount = UFO.UnactiveCount + 1;
  51.          if(UFO.UnactiveCount > 50)
  52.          {
  53.             ActivateColumn(false);
  54.             UFO.Active = true;
  55.          }
  56.       }
  57.       if(AbductedAtOnce > 1)
  58.       {
  59.          eval("S" + LastAbducted).Bonus.gotoAndPlay(2);
  60.          if(AbductedAtOnce == 2)
  61.          {
  62.             eval("S" + LastAbducted).Bonus.Value.gotoAndStop(1);
  63.             eval("S" + LastAbducted).Bonus.Value.Points = _parent.level * 50;
  64.          }
  65.          if(AbductedAtOnce == 3)
  66.          {
  67.             eval("S" + LastAbducted).Bonus.Value.gotoAndStop(2);
  68.             eval("S" + LastAbducted).Bonus.Value.Points = _parent.level * 150;
  69.          }
  70.          _parent.Score += eval("S" + LastAbducted).Bonus.Value.Points;
  71.       }
  72.       AbductedAtOnce = 0;
  73.       if(_quality != "LOW")
  74.       {
  75.          STC++;
  76.          if(STC == 10)
  77.          {
  78.             time = new Date();
  79.             LastFrameTime = time.getTime();
  80.          }
  81.          if(STC > 10)
  82.          {
  83.             time = new Date();
  84.             TimePerFrame = time.getTime() - LastFrameTime;
  85.             FramesSummary += TimePerFrame;
  86.             LastFrameTime = time.getTime();
  87.             if(STC >= 30)
  88.             {
  89.                AverageTime = FramesSummary / 20;
  90.                if(AverageTime > 70)
  91.                {
  92.                   if(_quality == "MEDIUM")
  93.                   {
  94.                      _quality = "LOW";
  95.                   }
  96.                   if(_quality == "HIGH")
  97.                   {
  98.                      _quality = "MEDIUM";
  99.                   }
  100.                }
  101.                STC = 0;
  102.                FramesSummary = 0;
  103.             }
  104.          }
  105.       }
  106.       if(UFO.XSpeed != 0)
  107.       {
  108.          UFO.XSpeed -= UFO.XSpeed / Math.abs(UFO.XSpeed) * 2;
  109.       }
  110.       if(UFO.ZSpeed != 0)
  111.       {
  112.          UFO.ZSpeed -= UFO.ZSpeed / Math.abs(UFO.ZSpeed);
  113.       }
  114.       if(UFO.XSpeed > 20)
  115.       {
  116.          UFO.XSpeed = 20;
  117.       }
  118.       if(UFO.XSpeed < -20)
  119.       {
  120.          UFO.XSpeed = -20;
  121.       }
  122.       if(UFO.ZSpeed > 10)
  123.       {
  124.          UFO.ZSpeed = 10;
  125.       }
  126.       if(UFO.ZSpeed < -10)
  127.       {
  128.          UFO.ZSpeed = -10;
  129.       }
  130.       _parent.UFO.gotoAndStop(11 - UFO.ZSpeed);
  131.       _parent.UFO._rotation = UFO.XSpeed;
  132.       MoveBullets();
  133.       _X = _X - UFO.XSpeed;
  134.       _Y = _Y - UFO.ZSpeed;
  135.       UFO.x = 585 - _X * 2;
  136.       UFO.z = 520 - _Y * 2;
  137.       Shadows.High.UFOShadow._x = UFO.x;
  138.       Shadows.High.UFOShadow._y = UFO.z;
  139.       Box = CalculateBox(UFO.x - 17,UFO.z + 7,1,1);
  140.       UFO.Boxx = Box.x;
  141.       UFO.Boxz = Box.z;
  142.       if(Map[UFO.Boxz][UFO.Boxx] == 0 or Map[UFO.Boxz][UFO.Boxx] > 600)
  143.       {
  144.          _parent.Panel.Light6.gotoAndStop(1);
  145.       }
  146.       else
  147.       {
  148.          _parent.Panel.Light6.gotoAndStop(3);
  149.       }
  150.       if(UFO.XSpeed == 0 and UFO.ZSpeed == 0 and UFO.FreeSlots > 0)
  151.       {
  152.          xi = Box.x - 1;
  153.          while(xi <= Box.x + 1)
  154.          {
  155.             zi = Box.z - 2;
  156.             while(zi <= Box.z + 2)
  157.             {
  158.                if(Map[zi][xi] > 0 and Map[zi][xi] < 300 and !eval("S" + Map[zi][xi]).Pacified and UFO.FreeSlots > 0)
  159.                {
  160.                   EmpltySlot = -1;
  161.                   f = 0;
  162.                   while(f < 3)
  163.                   {
  164.                      if(UFO.AbdSold[f] == 0)
  165.                      {
  166.                         EmptySlot = f;
  167.                         break;
  168.                      }
  169.                      f++;
  170.                   }
  171.                   if(EmptySlot != -1)
  172.                   {
  173.                      eval("S" + Map[zi][xi]).InAbduction = true;
  174.                      eval("S" + Map[zi][xi]).Pacified = true;
  175.                      FindPhase(eval("S" + Map[zi][xi]));
  176.                      eval("S" + Map[zi][xi]).Phase.Body.gotoAndPlay(46);
  177.                      UFO.AbdSold[EmptySlot] = Map[zi][xi];
  178.                      ActivateColumn(true);
  179.                      UpdateSlots();
  180.                      LastAbducted = Map[zi][xi];
  181.                      AbductedAtOnce++;
  182.                      Map[zi][xi] = 0;
  183.                      eval("_parent.Panel.Indicator" + EmptySlot).gotoAndPlay(2);
  184.                   }
  185.                }
  186.                zi++;
  187.             }
  188.             xi++;
  189.          }
  190.       }
  191.       if(UFO.ReadyNum == 0)
  192.       {
  193.          _parent.Panel.Light4.gotoAndStop(3);
  194.       }
  195.       else
  196.       {
  197.          _parent.Panel.Light4.gotoAndStop(1);
  198.       }
  199.       if(UFO.Releasing and UFO.XSpeed == 0 and UFO.ZSpeed == 0)
  200.       {
  201.          UFO.Releasing = false;
  202.          if(Map[UFO.Boxz][UFO.Boxx] == 0 or Map[UFO.Boxz][UFO.Boxx] > 600)
  203.          {
  204.             ReadySold = -1;
  205.             f = 0;
  206.             while(f < 3)
  207.             {
  208.                if(UFO.AbdSold[f] > 0 and UFO.Ready[f])
  209.                {
  210.                   ReadySold = f;
  211.                   break;
  212.                }
  213.                f++;
  214.             }
  215.             if(ReadySold != -1)
  216.             {
  217.                UFO.Releasing = false;
  218.                ActivateColumn(true);
  219.                Map[UFO.Boxz][UFO.Boxx] = UFO.AbdSold[ReadySold];
  220.                eval("Shadows.SoldShad" + UFO.AbdSold[ReadySold])._x = eval("S" + UFO.AbdSold[ReadySold])._x = UFO.x - 17;
  221.                eval("Shadows.SoldShad" + UFO.AbdSold[ReadySold])._y = eval("S" + UFO.AbdSold[ReadySold])._y = UFO.z - 7;
  222.                eval("S" + UFO.AbdSold[ReadySold]).swapDepths(UFO.Boxx + MapW * (UFO.Boxz * 4 + 2));
  223.                eval("S" + UFO.AbdSold[ReadySold])._visible = true;
  224.                eval("S" + UFO.AbdSold[ReadySold]).Phase.gotoAndStop(6);
  225.                UFO.AbdSold[ReadySold] = 0;
  226.                UFO.Ready[ReadySold] = false;
  227.                UFO.ReadyNum--;
  228.                eval("_parent.Panel.Indicator" + ReadySold).gotoAndStop(1);
  229.                UpdateSlots();
  230.             }
  231.             else
  232.             {
  233.                UFO.Active = true;
  234.                RejSound.start();
  235.             }
  236.          }
  237.          else
  238.          {
  239.             NoLanding._x = UFO.x - 21;
  240.             NoLanding._y = UFO.z - 7;
  241.             NoLanding.gotoAndPlay(2);
  242.             UFO.Active = true;
  243.             RejSound.start();
  244.          }
  245.       }
  246.       ii = 1;
  247.       while(ii <= TotSold)
  248.       {
  249.          CheckShadow(eval("S" + ii));
  250.          if(!eval("S" + ii).Dead and !eval("S" + ii).Pacified)
  251.          {
  252.             if(Spin(eval("S" + ii)))
  253.             {
  254.                if(eval("S" + ii).Follow)
  255.                {
  256.                   FindDirection(eval("S" + ii),S299.x,S299.z);
  257.                }
  258.                else
  259.                {
  260.                   eval("S" + ii).Attack = 0;
  261.                   MinDis = 150;
  262.                   ss = 1;
  263.                   while(ss <= TotSold)
  264.                   {
  265.                      Dis = Math.abs(eval("S" + ii).x - eval("S" + ss).x) + Math.abs(eval("S" + ii).z - eval("S" + ss).z);
  266.                      if(ss != ii and Dis < MinDis and eval("S" + ii).Army != eval("S" + ss).Army and !eval("S" + ss).Dead and !eval("S" + ss).Pacified)
  267.                      {
  268.                         eval("S" + ii).Attack = ss;
  269.                         eval("S" + ii).AttackDis = Dis;
  270.                         MinDis = Dis;
  271.                      }
  272.                      ss++;
  273.                   }
  274.                   if(eval("S" + ii).Attack > 0)
  275.                   {
  276.                      if(eval("S" + ii).AttackDis > 5 and random(eval("S" + ii).AttackDis) == 0)
  277.                      {
  278.                         eval("S" + ii).Go = false;
  279.                      }
  280.                      if(eval("S" + ii).AttackDis > 5 and random(100 - eval("S" + ii).AttackDis) == 0)
  281.                      {
  282.                         eval("S" + ii).Go = true;
  283.                      }
  284.                      if(eval("S" + ii).AttackDis <= 5)
  285.                      {
  286.                         eval("S" + ii).Go = false;
  287.                      }
  288.                      if(eval("S" + ii).Go and eval("S" + ii).CurPos == eval("S" + ii).DesPos)
  289.                      {
  290.                         FindDirection(eval("S" + ii),eval("S" + eval("S" + ii).Attack).x,eval("S" + eval("S" + ii).Attack).z);
  291.                      }
  292.                      else if(eval("S" + ii).Shooting)
  293.                      {
  294.                      }
  295.                      eval("S" + ii).DesPos = CalcDir(eval("S" + ii),eval("S" + eval("S" + ii).Attack));
  296.                      eval("S" + ii).Shooting = true;
  297.                   }
  298.                   else
  299.                   {
  300.                      eval("S" + ii).Go = true;
  301.                      if(eval("S" + ii).Blocked or random(50) == 0)
  302.                      {
  303.                         if(random(2))
  304.                         {
  305.                            eval("S" + ii).dir = eval("S" + ii).dir + 1;
  306.                         }
  307.                         else
  308.                         {
  309.                            eval("S" + ii).dir--;
  310.                         }
  311.                         if(eval("S" + ii).dir > 3)
  312.                         {
  313.                            eval("S" + ii).dir -= 4;
  314.                         }
  315.                         if(eval("S" + ii).dir < 0)
  316.                         {
  317.                            eval("S" + ii).dir += 4;
  318.                         }
  319.                      }
  320.                      eval("S" + ii).xGo = eval("S" + ii).XDM[eval("S" + ii).dir];
  321.                      eval("S" + ii).zGo = eval("S" + ii).ZDM[eval("S" + ii).dir];
  322.                   }
  323.                }
  324.                if(eval("S" + ii).Go)
  325.                {
  326.                   eval("S" + ii).DesPos = eval("S" + ii).DirPos[eval("S" + ii).dir];
  327.                }
  328.                if(eval("S" + ii).CurPos == eval("S" + ii).DesPos)
  329.                {
  330.                   if(eval("S" + ii).Go)
  331.                   {
  332.                      eval("S" + ii).Shooting = false;
  333.                      eval("S" + ii).Phase.gotoAndStop(eval("S" + ii).dir + 1);
  334.                      eval("S" + ii).Phase.Body.play();
  335.                      Move(eval("S" + ii));
  336.                   }
  337.                   else
  338.                   {
  339.                      eval("S" + ii).Phase.gotoAndStop(5);
  340.                      eval("S" + ii).Phase.Body.gotoAndStop(eval("S" + ii).CurPos);
  341.                      if(!(Map[eval("S" + ii).z][eval("S" + ii).x] = eval("S" + ii).ind))
  342.                      {
  343.                      }
  344.                   }
  345.                   if(eval("S" + ii).Shooting and random(eval("S" + ii).AttackDis + 10) == 0)
  346.                   {
  347.                      Shoot(eval("S" + ii),eval("S" + eval("S" + ii).Attack));
  348.                      eval("S" + ii).Shooting = false;
  349.                   }
  350.                }
  351.                else
  352.                {
  353.                   eval("S" + ii).Blocked = false;
  354.                }
  355.             }
  356.          }
  357.          ii++;
  358.       }
  359.    }
  360. }
  361.